local joy__jingyesi = fk.CreateSkill {

  name = "joy__jingyesi",

  tags = {  },

}



joy__jingyesi:addEffect(fk.EventPhaseEnd, {
  name = "joy__jingyesi",
  events = {fk.EventPhaseEnd},
  anim_type = "drawcard",
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(joy__jingyesi.name) and target == player and (player.phase == Player.Play or player.phase == Player.Discard)
  end,
  on_cost = function (self, event, target, player, data)
    return player.phase == Player.Discard or player.room:askForSkillInvoke(player, joy__jingyesi.name)
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    if player.phase == Player.Play then
      local id = room:getNCards(1)[1]
      table.insert(room.draw_pile, 1, id)
      room:askForUseRealCard( player, {id}, ".", joy__jingyesi.name, "#joy__jingyesi-use:::"..Fk:getCardById(id):toLogString(),
      {expand_pile = {id}})
    else
      player:drawCards(1, joy__jingyesi.name, "bottom")
    end
  end,
})

return joy__jingyesi